﻿
namespace Patterns4Net.ArchitectureExplorer.Diagram.Services.AbstractionLevels
{
    using System.IO;
    using Mono.Cecil;
    using Patterns4Net.ArchitectureExplorer.Diagram.Services;
    using Patterns4Net.Attributes;
    using Patterns4Net.Core.CecilExtensions;

    [DiagramUpdaterExport(Order = 100)]
    public class BasicAbstractionLevelProvider : DiagramVisitor, IDiagramUpdater
    {
        public void UpdateDiagram(Diagram diagram, TextWriter output)
        {
            diagram.Accept(this);
        }

        public override void Visit(TypeInfo typeInfo)
        {
            var typeDef = typeInfo.GetTag<TypeDefinition>();
            if (typeDef.IsNested ||
                typeDef.IsPublic == false ||
                typeDef.IsStaticType())
            {
                typeInfo.AbstractionLevel = AbstractionLevel.Low;
            }
        }
    }
}
